<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
        // let obj = {name:'zf'}
        // console.log(obj.name) //"zf"  获取时get
        // obj.name = "lucy";
        // console.log(obj)  //{name:'lucy'} 设置set

        let obj = {};
        let tempObj = {name:'zf'};
        Object.defineProperty(obj,"name",{
            get(){
               return tempObj.name    
            },
            set(val){
                tempObj.name = val;
            }
        })
       obj.name="lucy";
       console.log(obj);



</script>